﻿using System;

namespace Transformable_Engine_v2.Engine.Animation.RotationAnimation
{
    public class RotationUniformLinearAnimation : BaseAnimation
    {
        public RotationUniformLinearAnimation(double delay, double speed, bool autoStart = true)
            : this(delay, speed, 0, autoStart)
        {
        }

        public RotationUniformLinearAnimation(double delay, double speed, double acceleration, bool autoStart = true)
            : base(0, false, delay, autoStart)
        {
            Speed = speed;
            Acceleration = acceleration;
        }

        public double Speed { get; private set; }
        public double Acceleration { get; private set; }
        public IRotationAnimatable AffectedObject { private get; set; }

        public override void Update(TimeSpan gameTime)
        {
            
        }

        public override void FixedStepUpdate(TimeSpan gameTime)
        {
            AffectedObject.AddToRotation(Speed * gameTime.TotalSeconds);

            Speed += Acceleration*gameTime.TotalSeconds;

            base.FixedStepUpdate(gameTime);
        }

        public override void Die()
        {
            AffectedObject = null;
            base.Die();
        }
    }
}